<template>
  <hotnewsBase :tabs="tabs" @change="tabChage"></hotnewsBase>
</template>

<script>
import hotnewsBase from "./hotnewsBase.vue";
export default {
  components: {
    hotnewsBase,
  },
  data() {
    return {
      tabs: [{ key: "today",name:"今日" }, { key: "threeday" ,name:"近三天"}, { key: "month" ,name:"近一个月"}],
    };
  },
  methods: {
    tabChage(key, callback) {
      //根据 key 自己 解析请求条件
      //模拟请求获取数据

      this.getList('url','test:'+key,result=>{
        //请求原数据转为组件的数据格式
        debugger
        var listdata = result.map(r=>{
          return {title:r.name}
        })
        callback(listdata)
      })
    },
    getList(url, data, callback) {
      //模拟响应请求数据
      //
      var data = [
        {
          name: url+data,
        },
        {
          name: "Ant Design Title 2",
        },
        {
          name: "Ant Design Title 3",
        },
        {
          name: "Ant Design Title 4",
        },
      ];
      if (typeof callback == "function") callback(data);
    },
  },
};
</script>

<style></style>
